package com.CST.controller.cb;

import com.CST.util.ItemFtp;
import com.CST.util.UploadUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @Description:
 * @Author: wzw
 * @Time: 2020/12/14 17:37
 */
@Api(tags = "上传")
@RequestMapping("/uploaderController")
@RestController
public class UploaderController {

    /**
     * 保存到pdf
     *
     * @param file
     * @return
     * @throws IOException
     */
    @ApiOperation("上传文件")
    @PostMapping("/uploaderFile")
    public Object uploaderFile(@RequestParam("file") MultipartFile file) throws IOException {
	  return ItemFtp.uploadFile(file.getOriginalFilename(), file.getInputStream());
    }

    @ApiOperation("上传文件到本地服务器")
    @PostMapping("/uploadOne")
    public Object uploadOne(@RequestParam("file") MultipartFile file) {
	  return UploadUtils.uploadOne(file);
    }

}
